package com.java.socket.udp.mulitclient.multithread;

import com.java.socket.udp.mulitclient.multithread.receiver.ReceiverThread;
import com.java.socket.udp.mulitclient.multithread.sender.SenderThread;

import java.net.DatagramSocket;
import java.net.SocketException;

/**
 * @author xzmeasy
 * @version 1.0
 * @since 星期二 十二月,2018
 */
public class MultiThreadUdp {

    public static void main(String[] args) {
        try {
            DatagramSocket rd1 = new DatagramSocket(8890);
            DatagramSocket sd1 = new DatagramSocket();

            DatagramSocket rd2 = new DatagramSocket(8891);
            DatagramSocket sd2 = new DatagramSocket();

            ReceiverThread receiverThread = new ReceiverThread(sd1, rd1);
            SenderThread senderThread = new SenderThread(sd2, rd2);

            Thread rt = new Thread(receiverThread);
            Thread st = new Thread(senderThread);

            rt.start();
            st.start();
        } catch (SocketException e) {
            e.printStackTrace();
        }
    }

}
